package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Dict;
import com.ruoyi.system.service.IDictService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 城市疫情信息与风险区显示Controller
 * 
 * @author 凡诚
 * @date 2022-11-04
 */
@RestController
@RequestMapping("/system/dicts")
public class DictController extends BaseController
{
    @Autowired
    private IDictService dictService;

    /**
     * 查询城市疫情信息与风险区显示列表
     */
    @PreAuthorize("@ss.hasPermi('system:dicts:list')")
    @GetMapping("/list")
    public TableDataInfo list(Dict dict)
    {
        startPage();
        List<Dict> list = dictService.selectDictList(dict);
        return getDataTable(list);
    }

    /**
     * 导出城市疫情信息与风险区显示列表
     */
    @PreAuthorize("@ss.hasPermi('system:dicts:export')")
    @Log(title = "城市疫情信息与风险区显示", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Dict dict)
    {
        List<Dict> list = dictService.selectDictList(dict);
        ExcelUtil<Dict> util = new ExcelUtil<Dict>(Dict.class);
        util.exportExcel(response, list, "城市疫情信息与风险区显示数据");
    }

    /**
     * 获取城市疫情信息与风险区显示详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dicts:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(dictService.selectDictById(id));
    }

    /**
     * 新增城市疫情信息与风险区显示
     */
    @PreAuthorize("@ss.hasPermi('system:dicts:add')")
    @Log(title = "城市疫情信息与风险区显示", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Dict dict)
    {
        return toAjax(dictService.insertDict(dict));
    }

    /**
     * 修改城市疫情信息与风险区显示
     */
    @PreAuthorize("@ss.hasPermi('system:dicts:edit')")
    @Log(title = "城市疫情信息与风险区显示", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Dict dict)
    {
        return toAjax(dictService.updateDict(dict));
    }

    /**
     * 删除城市疫情信息与风险区显示
     */
    @PreAuthorize("@ss.hasPermi('system:dicts:remove')")
    @Log(title = "城市疫情信息与风险区显示", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dictService.deleteDictByIds(ids));
    }
}
